﻿using ContainerHost.ServiceModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace ContainerHost.Tests
{


    /// <summary>
    ///This is a test class for IContainerTest and is intended
    ///to contain all IContainerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class UnityContainerFacadeTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        internal virtual IContainer CreateIContainer()
        {
            // TODO: Instantiate an appropriate concrete class.
            IContainer target = new Unity.UnityContainerFacade();
            return target;
        }

        /// <summary>
        ///A test for Resolve
        ///</summary>
        [TestMethod()]
        public void Should_Resolve_T()
        {
            IContainer target = CreateIContainer();
            Type t = Type.GetType("ContainerHost.Tests.SimpleClass, ContainerHost.Tests");
            SimpleClass actual = (SimpleClass)target.Resolve(t);
            
            Assert.IsTrue(actual != null);
            Assert.IsTrue(actual.IntProperty == 0);
        }
    }

    public class SimpleClass
    {
        /// <summary>
        /// Initializes a new instance of the SimpleClass class.
        /// </summary>
        public SimpleClass()
        {
            
        }

        public int IntProperty { get; set; }
    }
}
